<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link href="__PUBLIC__/Css/Admin/Bootstrap/bootstrap.min.css" rel="stylesheet"  >
<link href="__PUBLIC__/Js/jqui/jquery-ui.min.css" rel="stylesheet"  >
<script src='__PUBLIC__/Js/jquery-3.1.0.min.js'></script>
<script src='__PUBLIC__/Js/jqPaginator.js'></script>
<script src='__PUBLIC__/Js/jqui/jquery-ui.min.js'></script>
<style>
	   #first,span{
		   float:left;
	     }
		  #second{
		   display:none;
		   float:left;
		 }
		 p{
		 	clear:both;
		 }
</style>
</head>
<body>
	<h2>商品修改</h2>
	<div id='msg' class="btn btn-warning" style="display:none;position:absolute;margin-left:500px;"></div>
	<ol class="breadcrumb">
	  <li><a href="javascript:void(0)">修改基本信息</a></li>
	  <li class="active">修改商品图片</li>
	 
    </ol>
	<div class="panel panel-default">
	    <div class="panel-body">
	       <span>商品分类:<{$pro.顶级分类}>-><{$pro.二级分类}></span><select name="type" id="first" class="form-control" style="width:110px;">
					          </select>	
							  <select name="type2" id="second" class="form-control" style="width:110px;">
					          </select>			 	  
	<p>商品名称:<input type="text" name='goods_name'value='<{$pro.goods_name}>' class="form-control" style="width:300px;" /></p>
	<p>是否上下架:<input type="radio" name='updown' value='1' <if condition="($pro.up_down eq 1)">checked</if> />上架
	<input type="radio" name='updown'value='0' <if condition="($pro.up_down eq 0)"> checked </if>/>下架</p>
	<p>商品描述:</p>
	<textarea name="desc" id="desc" cols="30" rows="10" class="form-control"><{$pro.goods_desc}></textarea>
	<br/>
	  <a href="<{:U('Goods/goods')}>"><button type='button' name='but_add' id='pre' class='btn btn-primary'>上一步</button></a>
	  <button type='button' name='but_add' id='next' class='btn btn-primary'>下一步</button>	 
	    </div>
     </div>
<script>
	$(function(){
		$('#next').click(function(){
		var cate_id=$('#second :selected').val();
		var name=$("[name='goods_name']").val();
		var ifshow=$("[type='radio']:checked").val();
		var desc=$("#desc").val();
		if($('#first :selected').val()==''){
			    $('#msg').text("数据填写不完整");
				$('#msg').css("display","block");
				setTimeout(function(){$('#msg').fadeOut('slow');},2000);
				return false;
		}
		$.get("<{:U('doeditpro')}>",{cate_id:cate_id,goods_name:name,up_down:ifshow,goods_desc:desc},function(data){
			if(data.status==0){
				$('#msg').text(data.msg);
				$('#msg').css("display","block");
				setTimeout(function(){$('#msg').fadeOut('slow');},2000);
			}else{
				location.href="<{:U('editpronext')}>";
			}
		},'json');
		});
  //获取一级菜单
		 $.get("<{:U('docate_list')}>",{id:0},function(data){
			 var html="<option value=''>顶级分类</option>";			 
			 $(data).each(function(k,v){
		        html += '<option value="'+v.id+'">'+v.cate_name+'</option>'; 		
			  $('#first').html(html);
			});
         },'json' );  
  //获取二级菜单
 
  $('#first').change(function(){
        $('[name=type2]').css('display','block');
	    var html="<option value=''>二级分类</option>";
	     $.get("<{:U('docate_list')}>",{id:$('[name=type]').val()},function(data){
			 $(data).each(function(k,v){
		        html += '<option value="'+v.id+'">'+v.cate_name+'</option>'; 
			  $('#second').html(html);
			});
         },
        'json'
      );  
  });

		 
	});
	
</script>
  
</body>
</html>